package com.qf.blog.vo;


import lombok.Data;

import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import static com.qf.blog.commons.utils.TimeAgoUtils.format;

@Data
public class Topic  {
    //帖子ID
    private Integer id;
    //作者ID
    private Integer userId;
    //帖子点赞
    private Integer likeStatus;
    //帖子点赞数
    private Integer likeCount;
    //作者头像
    private String headerUrl;
    //作者名字
    private String username;
    //帖子标题
    private String title;
    //帖子内容
    private String content;
    //帖子类型（置顶）
    private Integer type;
    //帖子状态（加精）
    private Integer status;
    //帖子创建时间
    private Timestamp createTime;
    //帖子评论数量
    private Integer commentCount;
    //帖子分数
    private Double score;

    public String getCreateTime() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        Date parse = null;
        try {
            String s = createTime.toString();
            parse = sdf.parse(s);
        } catch (ParseException e) {
            e.printStackTrace();
        }

        String format = format(parse);
        return format;
    }
}
